package com.joysuch.wwyt.bp.controller;


import com.joysuch.wwyt.bp.entity.vo.RewardRulesVo;
import com.joysuch.wwyt.bp.service.BpRewardRulesService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.enums.Status;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author heqifeng
 * @since 2022-01-06
 */
@RestController
@Api("个人绩效奖惩规则设置")
@RequestMapping("/bp/bp-reward-rules")
public class BpRewardRulesController {

    @Autowired
    BpRewardRulesService rulesService;

    @PostMapping("saveBatch")
    @ApiOperation("批量保存")
    public ResultBean saveBatch(@RequestBody List<RewardRulesVo> rewardRulesVos) {
        if (rulesService.saveOrUpdateRulesBatch(rewardRulesVos)) {
            return ResultBean.defaultSuccessResult();
        }else {
            return ResultBean.fail(Status.FAILED);
        }
    }

    @RequestMapping("getAll")
    @ApiOperation("获取奖惩规则")
    public ResultBean getAll() {
        return ResultBean.success(rulesService.getAllRules());
    }
}